
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <meta charset="utf-8">
  <title>登入</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="fly,layui,前端社区">
  <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
  <link rel="stylesheet" href="res/layui/css/layui.css">
  <link rel="stylesheet" href="res/css/global.css">
</head>
<body>

<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="/">
      <img th:src="${index[0].blogLogo}" alt="layui" width="200" height="40">
    </a>
    <ul class="layui-nav fly-nav-user">
      <!-- 未登入的状态 -->
      <shiro:guest>
      <li class="layui-nav-item">
        <a class="iconfont icon-touxiang layui-hide-xs" href="user"></a>
      </li>
      <li class="layui-nav-item">
        <a href="user">登入</a>
      </li>
      <li class="layui-nav-item">
        <a href="user/userregist">注册</a>
      </li>
        </shiro:guest>
<!--      <li class="layui-nav-item layui-hide-xs">
        <a href="/app/qq/" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" title="QQ登入" class="iconfont icon-qq"></a>
      </li>
      <li class="layui-nav-item layui-hide-xs">
        <a href="/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})" title="微博登入" class="iconfont icon-weibo"></a>
      </li>-->
    </ul>
  </div>
</div>

<div class="layui-container fly-marginTop">
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title">
        <li class="layui-this">登入</li>
        <li><a href="user/userregist">注册</a></li>
      </ul>
      <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <div class="layui-form layui-form-pane">
            <div class="layui-form">
              <div class="layui-form-item">
                <label for="LAY-user-login-username" class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                  <input type="text" id="LAY-user-login-username" name="username"  placeholder="用户名" required lay-verify="required" autocomplete="off" class="layui-input name">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="LAY-user-login-password" class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="LAY-user-login-password" name="password" placeholder="密码" required lay-verify="required" autocomplete="off" class="layui-input pass">
                </div>
              </div>
              <div class="layui-form-item" style="margin-bottom: 20px;" lay-filter="test2">
                <input type="checkbox" name="rememberMe" id="rememberMe" class="remember" lay-skin="primary" title="记住密码">
              </div>
              <div class="layui-form-item">
                <button class="layui-btn" lay-submit lay-filter="LAY-user-login-submit">立即登录</button>
                <span style="padding-left:20px;">
                  <a href="user/retrieve">忘记密码？</a>
                </span>
              </div>
              <div class="layui-form-item fly-form-app">
                <span>或者使用社交账号登入</span>
                <a href="login/qq" class="iconfont icon-qq" title="QQ登入" onclick="layer.msg('正在绑定QQ登录', {icon:16, shade: 0.1, time:0})"></a>
                <a href="javascript:;" class="iconfont icon-weibo tchu" title="微博登入"></a>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<footer th:replace="footer::header-fragment"></footer>

<script src="res/layui/layui.js"></script>
<script>
layui.cache.page = 'user';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: 'res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "3.0.0"
  ,base: 'res/mods/'
}).extend({
  fly: 'index'
}).use(['fly', 'user','layer'], function(){
    var $ = layui.$
            ,form = layui.form
            ,layer = layui.layer;

  $('.tchu').on('click', function(){
    layer.open({
      title: '更新中'
      ,content: '开发中，请等待！'
    });
  });
  //提交
  form.on('submit(LAY-user-login-submit)', function(obj){
    //获取表单参数
    var date = obj.field;
    var rememberMe = $("#rememberMe").is(':checked');
    //请求接口
    $.post('user/login',{
      "username":date.username,
      "password":date.password,
      "rememberMe":rememberMe
    },function (res){
      if (res.success){
        layer.msg('登录成功', {
          icon: 1
          ,time: 1000
        }, function(){
          location.href = 'user/userindex'; //跳转到后台首页
        });
      }else {
        layer.msg('登录失败', {
          icon: 1
          ,time: 1000
        }, function(){
          location.href = 'user'; //跳转到登录页
        });
      }
    },'json');

    return false;
  });

  form.render("checkbox");
});
</script>

</body>
</html>